//
//  CCPopViewVC.swift
//  swift_weibo
//
//  Created by ccl on 16/3/4.
//  Copyright © 2016年 LittleBoy. All rights reserved.
//

import UIKit

class CCPopViewVC: UIViewController, UITableViewDelegate, UITableViewDataSource{

    override func viewDidLoad() {
        super.viewDidLoad()
        creatUI();
      }

    func creatUI(){
        
        view.addSubview(backView);
        backView.addSubview(tabelView);
        
        backView.translatesAutoresizingMaskIntoConstraints = false;
        view.addConstraints( NSLayoutConstraint.constraintsWithVisualFormat("H:|[sub]|", options: NSLayoutFormatOptions.AlignAllBaseline, metrics: nil , views: ["sub" : backView]));
        view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[sub]|", options: NSLayoutFormatOptions.AlignAllBaseline, metrics: nil , views:["sub" : backView]));

        tabelView.translatesAutoresizingMaskIntoConstraints = false;
       view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-8-[sub]-8-|", options: NSLayoutFormatOptions.AlignAllBaseline, metrics: nil , views: ["sub" : tabelView]));
        view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-(16)-[sub]-8-|", options: NSLayoutFormatOptions.AlignAllBaseline, metrics: nil , views: ["sub" : tabelView]));


       
    }
    
 
  // MARK: tableView代理
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
          return 10;
      }
    
    static let recellID = "reCellID";
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    
        var cell = tableView.dequeueReusableCellWithIdentifier(CCPopViewVC.recellID);
        
        if cell == nil{
            cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: CCPopViewVC.recellID);
        }
        cell?.textLabel?.text = "hahah";
        return cell!;
        
    }
  
    
  // MARK: 懒加载
    lazy var backView:UIImageView = {
     
        let imgV = UIImageView();
        imgV.image = UIImage(named: "popover_background");
        imgV.userInteractionEnabled  = true;
        
       // imgV.frame = self.view.bounds;
        return imgV;
    }()
    
    lazy var tabelView:UITableView = {
    
        let tabview = UITableView();
        tabview.delegate = self;
        tabview.dataSource = self;
        return tabview;
    }()
}
